package misc

import (
	"gvm/instructions/base"
	"gvm/native/basic"
	"gvm/rtda"
)

func RegisterVm() (className string, methods []*basic.NaMethod) {
	return "sun/misc/VM", []*basic.NaMethod{
		{
			"initialize",
			"()V",
			initialize,
		},
	}
}

// private native static void initialize();
func initialize(jFrame *rtda.JFrame) {
	classLoader := jFrame.Method().Class().GetClassLoader()
	jlSysClass := classLoader.LoadClass("java/lang/System")
	initSysCLass := jlSysClass.GetStaticMethod("initializeSystemClass", "()V")
	base.InvokeMethod(jFrame, initSysCLass)
}
